package com.magic.ch02_二分与前缀和.前缀和;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

/**
 * created by mzk on 2020/07/20
 */
public class Main {
    static int[] a = new int[100010];
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out);
        String[] read = br.readLine().split(" ");
        int n = Integer.parseInt(read[0]);
        int m = Integer.parseInt(read[1]);


        read = br.readLine().split(" ");
        for (int i = 1; i <= n; i++) {
            a[i] = a[i - 1] + Integer.parseInt(read[i - 1]);
        }

        for(int i = 0 ; i < m ; i++){
            read = br.readLine().split(" ");
            int k1 = Integer.parseInt(read[0]);
            int k2 = Integer.parseInt(read[1]);

            pw.print(a[k2]-a[k1-1]+"\n");
        }
        br.close();
        pw.flush();
        pw.close();
    }
}
